﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Configuration;

public partial class Error : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
            showErrorMessageAndSendMail();
    }

    void showErrorMessageAndSendMail()
    {
        #region 顯示錯誤訊息
        if (Message.LastException != null)
        {
            Label1.Text = "錯誤訊息：" + Message.LastException.Message.ToString();
        }
        else
            Label1.Text = "沒有錯誤訊息";
        #endregion

        //Mailer mailer;
        #region send mail to Administrator
        if (bool.Parse(ConfigurationManager.AppSettings.Get("EnableMail")))
        {
            Mailer mailer = (Mailer)Session["SendMail"];
            mailer.send("OTC_TR報送系統發生錯誤.", Label1.Text);
        }
        #endregion
    }
}
